home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_weap_raildet_m.cog < prev    next >
Text File  |  1998-02-25  |  7KB  |  269 lines

  1. # Jedi Knight Missions Cog Script
  2. #
  3. # WEAP_RAILDET_M.COG
  4. #
  5. # WEAPON 7 Script - Rail Detonator Gun
  6. #
  7. # This is a missile launcher type of weapon. It sends out an explosive device with
  8. #  two options, impact or trigger explosion. The charge with the trigger option will
  9. #  stick to a wall.
  10. #
  11. # - Not affected by MagSealed sectors/surfaces.
  12. #
  13. # [YB & CYW] + [RF]
  14. #
  15. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  16.  
  17.  
  18. symbols
  19.  
  20. model       povModel=rldv.3do                   local
  21. model       povModel_m=rldv_m.3do               local
  22. model       weaponMesh=rldg.3do                 local
  23. sound       mountSound=RailChargeArm01.WAV      local
  24. sound       dismountSound=PutWeaponAway01.wav   local
  25. sound       fireSound=RailChargeFire01.WAV      local
  26. sound       outSound=RailChargeEmpty01.WAV      local
  27. sound            failSound=weapfail.wav                    local
  28.  
  29. thing       player                              local
  30.  
  31. keyframe    mountAnim=RldVmnt.key               local
  32. keyframe    dismountAnim=RldVdis.key            local
  33. keyframe    povfireAnim=RldVpst1.key            local
  34. keyframe    holsterAnim=kyhlstr.key             local
  35.  
  36. template    projectile=+raildet                 local
  37. template    projectile2=+raildet2               local
  38. template        projectileB=+dudrail                        local
  39.  
  40. thing       rail                                local
  41.  
  42. flex        fireWait=1.0                        local
  43. flex        powerBoost                          local
  44. flex        autoAimFOV=25                       local
  45. flex        holsterWait                         local
  46.  
  47. keyframe    railAnim=rld0anim.key               local
  48.  
  49. int         trackID=-1                          local
  50. int         mode                                local
  51. int         holsterTrack                        local
  52.  
  53.  
  54. int         selectMode=1                        local
  55.  
  56. message     activated
  57. message     deactivated
  58. message     selected
  59. message     deselected
  60. #message     newplayer
  61. message     autoselect
  62. message     fire
  63. message     timer
  64.  
  65. end
  66.  
  67. # ========================================================================================
  68.  
  69. code
  70.  
  71. fire:
  72.    player = GetSourceRef();
  73.    mode = GetSenderRef();
  74.  
  75.    // Check that the player is still alive.
  76.    if(GetThingHealth(player) <= 0)
  77.    {
  78.       Return;
  79.    }
  80.  
  81.    // Check Ammo - If we are out, autoselect best weapon.
  82.    if(GetInv(player, 15) < 1.0)
  83.    {
  84.       PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
  85.       if(GetAutoSwitch() & 1)
  86.          SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
  87.       Return;
  88.    }
  89.  
  90.     if (GetInv(player, 93) > 0.0)
  91.         mode = 2;
  92.  
  93.     SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
  94.    jkPlayPOVKey(player, povfireAnim, 1, 0x38);
  95.    SetPOVShake('0.0 -.01 0.0', '4.0 0.0 0.0', .05, 80.0);
  96.  
  97.     if (mode == 2)
  98.     {
  99.         rail = FireProjectile(player, projectile[mode], failSound, 18, '0.0214 0.15 0.00', '0 0 0', 1.0, 0x00, autoAimFOV, autoAimFOV*2);
  100.     }
  101.     else
  102.     {
  103.         rail = FireProjectile(player, projectile[mode], fireSound, 18, '0.0214 0.15 0.00', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
  104.         if((mode == 1) && (rail != -1))
  105.         {
  106.             PlayKey(rail, railAnim, 1, 20);
  107.         }
  108.     }
  109.  
  110.    // Provide a kick backwards
  111.     if (mode != 2)
  112.         ApplyForce(player, VectorScale(GetThingLVec(player), -40));
  113.     else
  114.         SendMessageEx(GetThingClassCog(player), skill, 1100, 0, 0, 0);
  115.  
  116.    ChangeInv(player, 15, -1.0);
  117.  
  118.    powerBoost = GetInv(player, 63);
  119.    ChangeFireRate(player, fireWait/powerBoost);
  120.  
  121.    Return;
  122.  
  123. # ........................................................................................
  124.  
  125. activated:
  126.    player = GetSourceRef();
  127.    mode = GetSenderRef();
  128.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  129.    powerBoost = GetInv(player, 63);
  130.    ActivateWeapon( player, fireWait/powerBoost, mode );
  131.    Return;
  132.  
  133. # ........................................................................................
  134.  
  135. deactivated:
  136.    player = GetSourceRef();
  137.    mode = GetSenderRef();
  138.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  139.    DeactivateWeapon( player, mode );
  140.    Return;
  141.  
  142. # ........................................................................................
  143.  
  144. selected:
  145.    player = GetSourceRef();
  146.  
  147.    PlayMode(player, 41);
  148.    PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
  149.     if (GetInv(player, 67) == 0.0)
  150.         jkSetPOVModel(player, povModel);        // Kyle hand
  151.     else
  152.         jkSetPOVModel(player, povModel_m);    // Mara Hand
  153.    SetArmedMode(player, 1);
  154.    jkSetWeaponMesh(player, weaponMesh);
  155.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  156.  
  157.    trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
  158.    SetMountWait(player, GetKeyLen(mountAnim));
  159.    jkClearFlags(player, 0x5);
  160.    SetCurWeapon(player, 7);
  161.  
  162.    // Check Ammo - If we are out, autoselect best weapon.
  163.    if(GetInv( player, 15 ) < 1.0)
  164.    {
  165.       PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
  166.       if(GetAutoSwitch() & 1)
  167.          SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
  168.    }
  169.  
  170.    Return;
  171.  
  172. # ........................................................................................
  173.  
  174. deselected:
  175.    player = GetSourceRef();
  176.  
  177.    PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
  178.    jkPlayPOVKey( player, dismountAnim, 0, 18 );
  179.  
  180.    holsterWait = GetKeyLen(holsterAnim);
  181.    SetMountWait(player, holsterWait);
  182.    holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
  183.    SetTimerEx(holsterWait, 2, 0.0, 0.0);
  184.    if (trackID != -1)
  185.    {
  186.       jkStopPOVKey( player, trackID, 0 );
  187.       trackID = -1;
  188.    }
  189.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  190.  
  191.    Return;
  192.  
  193. # ........................................................................................
  194.  
  195. //newplayer:
  196. //   player = GetSourceRef();
  197. //
  198. //   // Make sure that if the player is respawning, the old mount isn't playing anymore.
  199. //   if (trackID != -1)
  200. //      jkStopPOVKey(player, trackID, 0);
  201. //
  202. //   Return;
  203.  
  204. # ........................................................................................
  205.  
  206. autoselect:
  207.    selectMode = GetSenderRef();
  208.    player = GetSourceRef();
  209.  
  210.    // If the player has the weapon
  211.    if(GetInv(player, GetWeaponBin(7)) != 0.0)
  212.    {
  213.       // If the player has ammo
  214.       if(GetInv(player, 15) != 0.0)
  215.       {
  216.  
  217.          // query for ammo
  218.          if(selectMode == -1)
  219.          {
  220.             ReturnEx(900.0);
  221.             Return;
  222.          }
  223.  
  224.          if((selectMode == 0) && !(GetAutoPickup() & 2))
  225.          {
  226.             ReturnEx(900.0);
  227.             Return;
  228.          }
  229.  
  230.          if((selectMode == 1) && !(GetAutoSwitch() & 2))
  231.          {
  232.             ReturnEx(900.0);
  233.             Return;
  234.          }
  235.  
  236.          if((selectMode == 2) && !(GetAutoPickup() & 2))
  237.          {
  238.             ReturnEx(900.0);
  239.             Return;
  240.          }
  241.  
  242.          ReturnEx(-2.0);
  243.          Return;
  244.  
  245.       }
  246.       else
  247.       {
  248.          ReturnEx(-1.0);
  249.          Return;
  250.       }
  251.    }
  252.    else
  253.    {
  254.       ReturnEx(-1.0);
  255.    }
  256.  
  257.    Return;
  258.  
  259. # ........................................................................................
  260.  
  261. timer:
  262.    StopKey(player, holsterTrack, 0.0);
  263.    Return;
  264.  
  265. end
  266.  
  267.  
  268.  
  269.